﻿
@{
    ViewBag.Title = "资金明细";
}
@section CSS{

}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            财务明细
            <small></small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">财务管理</a></li>
            <li class="active">财务明细</li>
        </ol>
    </section>
    <section>
        <div class="col-xs-12 ">
            <div class="box box-primary">
                <div class="box-body">
                    <div class="col-md-6 ">
                        <div class="info-box-content">
                            <span class="info-box-number"><small>可提现金额 ￥</small><b style="font-size:30px;">@(Model == null ? 0 : (Model.balances - Model.balance_due) > 0 ? (Model.balances - Model.balance_due).ToString("f2") : 0)</b> <small>万</small><a style="margin-left:15px;position:  relative;top: -5px;" href="javascript:void(0);" class="btn btn-default" onclick="admin_add('申请提现','/Finance/AddWithdrawal',500,400)">提 现</a></span>
                        </div>
                    </div>
                    <div class="col-md-3 ">
                        <div style="text-align:center;">
                            <span class="info-box-number">￥<b>@(Model == null ? 0 : Model.balance_settlement.ToString("f2"))</b> <small>元</small></span>
                            <span class="info-box-text" style="color:#c2c1c1;">累计收款</span>
                        </div>
                    </div>
                    <div class="col-md-3 ">
                        <div style="border-left:1px #cdcdcd solid;text-align:center;">
                            <span class="info-box-number">￥<b>@ViewBag.Withdrawal.ToString("f2") </b> <small>元</small></span>
                            <span class="info-box-text" style="color:#c2c1c1;">累计提现</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <section class="content">

        <div class="row">
            @*<div class="col-md-3 col-sm-6 col-xs-12">
                    <div class="info-box">
                        <span class="info-box-icon bg-green "><i class="ion ion-social-yen-outline"></i></span>

                        <div class="info-box-content">
                            <span class="info-box-text">余额</span>
                            <span class="info-box-number">￥@(Model == null ? 0 : (Model.balances + Model.balance_freeze).ToString("f2"))<small>元</small></span>
                            可用余额 <b>￥@(Model == null ? 0 : (Model.balances - Model.balance_due) > 0 ? (Model.balances - Model.balance_due).ToString("f2") : 0)</b> <small>元</small>
                        </div>
                        <!-- /.info-box-content -->
                    </div>
                    <!-- /.info-box -->
                </div>*@
            <!-- /.col -->
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-yellow"><i class="fa ion-ios-timer-outline "></i></span>

                    <div class="info-box-content">
                        <span class="info-box-text">待结算</span>
                        <span class="info-box-number">￥@ViewBag.Settlementing.ToString("f2")<small>元</small></span>
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-teal"><i class="ion ion-social-buffer-outline"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">保证金</span>
                        <span class="info-box-number">￥@(Model == null ? 0 : Model.deposit.ToString("f2"))<small>元</small></span>
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>
            <!-- /.col -->
            <!-- fix for small devices only -->
            <div class="clearfix visible-sm-block"></div>
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-aqua"><i class="ion ion-ios-locked-outline"></i></span>

                    <div class="info-box-content">
                        <span class="info-box-text">冻结资金</span>
                        <span class="info-box-number">￥@(Model == null ? 0 : Model.balance_freeze.ToString("f2"))<small>元</small></span>
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-red"><i class="fa ion-ios-bell-outline "></i></span>

                    <div class="info-box-content">
                        <span class="info-box-text">欠款</span>
                        <span class="info-box-number">￥@(Model == null ? 0 : Model.balance_due.ToString("f2"))<small>元</small></span>
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>

        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active" id="li_1"><a href="#tab_1" id="a_tab_1" data-toggle="tab">结算记录</a></li>
                        <li class="" id="li_2"><a href="#tab_2" id="a_tab_2" data-toggle="tab">提现记录</a></li>
                        <li class="" id="li_3"><a href="#tab_3" id="a_tab_3" data-toggle="tab">扣款记录</a></li>
                        <li class="" id="li_4"><a href="#tab_4" id="a_tab_4" data-toggle="tab">冻结记录</a></li>
                        <li class="" id="li_5"><a href="#tab_5" id="a_tab_5" data-toggle="tab">欠款记录</a></li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="tab_1">
                            <table id="DataList1" class="table table-bordered table-striped table-hover ">
                                <thead>
                                    <tr>
                                        <th>交易时间</th>
                                        <th>流水编号</th>
                                        <th>订单编号</th>
                                        <th>交易类型</th>
                                        <th>收支金额(元)</th>
                                        <th>收支类型</th>
                                        <th width="200">备注</th>
                                        <th>详情</th>
                                    </tr>
                                </thead>
                                <tbody> </tbody>
                            </table>

                        </div>
                        <div class="tab-pane " id="tab_2">
                            <table id="DataList2" class="table table-bordered table-striped table-hover ">
                                <thead>
                                    <tr>
                                        <th>交易时间</th>
                                        <th>流水编号</th>
                                        <th>申请编号</th>
                                        <th>交易类型</th>
                                        <th>收支金额(元)</th>
                                        <th>收支类型</th>
                                        <th width="200">备注</th>
                                        @*<th>详情</th>*@
                                    </tr>
                                </thead>
                                <tbody> </tbody>
                            </table>

                        </div>
                        <div class="tab-pane" id="tab_3">
                            <table id="DataList3" class="table table-bordered table-striped table-hover ">
                                <thead>
                                    <tr>
                                        <th>交易时间</th>
                                        <th>流水编号</th>
                                        <th>订单编号</th>
                                        <th>交易类型</th>
                                        <th>收支金额(元)</th>
                                        <th>收支类型</th>
                                        <th width="200">备注</th>
                                        <th>详情</th>
                                    </tr>
                                </thead>
                                <tbody> </tbody>
                            </table>

                        </div>
                        <div class="tab-pane" id="tab_4">
                            <table id="DataList4" class="table table-bordered table-striped table-hover ">
                                <thead>
                                    <tr>
                                        <th>交易时间</th>
                                        <th>流水编号</th>
                                        <th>订单编号</th>
                                        <th>交易类型</th>
                                        <th>交易金额(元)</th>
                                        <th width="200">备注</th>
                                        <th>详情</th>
                                    </tr>
                                </thead>
                                <tbody> </tbody>
                            </table>

                        </div>
                        <div class="tab-pane" id="tab_5">
                            <table id="DataList5" class="table table-bordered table-striped table-hover ">
                                <thead>
                                    <tr>
                                        <th>交易时间</th>
                                        <th>流水编号</th>
                                        <th>订单编号ID</th>
                                        <th>交易类型</th>
                                        <th>交易金额(元)</th>
                                        <th width="200">备注</th>
                                        <th>详情</th>
                                    </tr>
                                </thead>
                                <tbody> </tbody>
                            </table>

                        </div>
                    </div>
                </div>

            </div>
        </div>
    </section>
</div>
<!-- /.content-wrapper -->
@section JS{
    <script>
        $(function () {
            //初始化表格
            GenerateTable1();
            GenerateTable2();
            GenerateTable3();
            GenerateTable4();
            GenerateTable5();
            //鼠标移动到该行变色
            $('.table-hover tbody').on('click', 'tr', function () {
                if ($(this).hasClass('selected')) {
                    $(this).removeClass('selected');
                }
                else {
                    u_table.$('tr.selected').removeClass('selected');
                    $(this).addClass('selected');
                }
            });
            $("#a_tab_1").click(function () {
                u_table1.fnDestroy();
                GenerateTable1();
            });
            $("#a_tab_2").click(function () {
                u_table2.fnDestroy();
                GenerateTable2();
            });
            $("#a_tab_3").click(function () {
                u_table3.fnDestroy();
                GenerateTable3();
            });
            $("#a_tab_4").click(function () {
                u_table4.fnDestroy();
                GenerateTable4();
            });
            $("#a_tab_5").click(function () {
                u_table5.fnDestroy();
                GenerateTable5();
            });
        });
        //结算
        function GenerateTable1() {
            u_table1 = $('#DataList1').dataTable({
                "lengthChange": true,
                "searching": false,
                "ordering": false,
                "iDisplayLength": 10,
                "bProcessing": true,
                "bServerSide": true,
                "fnServerParams": function (aoData) {
                    //var datemin = $('#startTime').val();
                    //var datemax = $("#endTime").val();
                    aoData.push(
                        { "name": "dateMin", "value": "" },
                        { "name": "dateMax", "value": "" },
                        { "name": "type", "value": 30 }
                    );
                },
                "sAjaxSource": "/finance/FinanceLogList",
                "aoColumns": [
                    {
                        "mDataProp": 'add_time', "mRender": function (data, type, full) {
                            return moment(data).format("YYYY-MM-DD HH:mm:ss");
                        }
                    },
                     //{ "mDataProp": 'id' },
                    { "mDataProp": "log_no" },
                    { "mDataProp": 'order_no' },
                     {
                         "mDataProp": 'trade_type', "mRender": function (data, type, full) {
                             return data==31?"订单退款":"货款结算";
                         }
                     },
                    {
                        "mDataProp": 'before', "mRender": function (data, type, full) {
                            return (full.end - data).toFixed(2);
                        }
                    },
                    {
                        "mDataProp": 'in_out', "mRender": function (data, type, full) {
                            return data==1?"收入":"支出";
                        }
                    },
                    { "mDataProp": 'remark' }
                    , {
                        "mDataProp": 'id', "mRender": function (data, type, full) {
                            return ' <a href = "/Order/GoodsOrder/' + full.order_id + '" target="_blank" class="btn btn-default"  title="详情">订单详情</a> ';
                        }
                    }
                ]
            });
        }
        //提现
        function GenerateTable2() {
            u_table2 = $('#DataList2').dataTable({
                "lengthChange": true,
                "searching": false,
                "ordering": false,
                "iDisplayLength": 10,
                "bProcessing": true,
                "bServerSide": true,
                "fnServerParams": function (aoData) {
                    //var datemin = $('#startTime').val();
                    //var datemax = $("#endTime").val();
                    aoData.push(
                        { "name": "dateMin", "value": "" },
                        { "name": "dateMax", "value": "" },
                        { "name": "type", "value": 20 }
                    );
                },
                "sAjaxSource": "/finance/FinanceLogList",
                "aoColumns": [
                    {
                        "mDataProp": 'add_time', "mRender": function (data, type, full) {
                            return moment(data).format("YYYY-MM-DD HH:mm:ss");
                        }
                    },
                    //{ "mDataProp": 'id' },
                    { "mDataProp": "log_no" },
                    { "mDataProp": 'relation_no' },
                     {
                         "mDataProp": 'trade_type', "mRender": function (data, type, full) {
                             return data == 20 ? "提现" : "提现手续费";
                         }
                     },
                    {
                        "mDataProp": 'before', "mRender": function (data, type, full) {
                            return (full.end - data).toFixed(2);
                        }
                    },
                    {
                        "mDataProp": 'in_out', "mRender": function (data, type, full) {
                            return data == 1 ? "收入" : "支出";
                        }
                    },
                    { "mDataProp": 'remark' }
                ]
            });
        }
        //扣款
        function GenerateTable3() {
            u_table3 = $('#DataList3').dataTable({
                "lengthChange": true,
                "searching": false,
                "ordering": false,
                "iDisplayLength": 10,
                "bProcessing": true,
                "bServerSide": true,
                "fnServerParams": function (aoData) {
                    //var datemin = $('#startTime').val();
                    //var datemax = $("#endTime").val();
                    aoData.push(
                        { "name": "dateMin", "value": "" },
                        { "name": "dateMax", "value": "" },
                        { "name": "type", "value": 31 }
                    );
                },
                "sAjaxSource": "/finance/FinanceLogList",
                "aoColumns": [
                    {
                        "mDataProp": 'add_time', "mRender": function (data, type, full) {
                            return moment(data).format("YYYY-MM-DD HH:mm:ss");
                        }
                    },
                   //{ "mDataProp": 'id' },
                    { "mDataProp": "log_no" },
                    { "mDataProp": 'order_no' },
                     {
                         "mDataProp": 'trade_type', "mRender": function (data, type, full) {
                             return "订单退款";
                         }
                     },
                    {
                        "mDataProp": 'before', "mRender": function (data, type, full) {
                            return (full.end - data).toFixed(2);
                        }
                    },
                    {
                        "mDataProp": 'in_out', "mRender": function (data, type, full) {
                            return data == 1 ? "收入" : "支出";
                        }
                    },
                    { "mDataProp": 'remark' }
                    , {
                        "mDataProp": 'id', "mRender": function (data, type, full) {
                            return ' <a href = "/Order/GoodsOrder/' + full.order_id + '" target="_blank" class="btn btn-default"  title="详情">订单详情</a> ';
                        }
                    }
                ]
            });
        }
        //冻结
        function GenerateTable4() {
            u_table4 = $('#DataList4').dataTable({
                "lengthChange": true,
                "searching": false,
                "ordering": false,
                "iDisplayLength": 10,
                "bProcessing": true,
                "bServerSide": true,
                "fnServerParams": function (aoData) {
                    //var datemin = $('#startTime').val();
                    //var datemax = $("#endTime").val();
                    aoData.push(
                        { "name": "dateMin", "value": "" },
                        { "name": "dateMax", "value": "" },
                        { "name": "type", "value": 1 }
                    );
                },
                "sAjaxSource": "/finance/FinanceReturnList",
                "aoColumns": [
                    {
                        "mDataProp": 'add_time', "mRender": function (data, type, full) {
                            return moment(data).format("YYYY-MM-DD HH:mm:ss");
                        }
                    },
                    //{ "mDataProp": 'id' },
                    { "mDataProp": 'return_no' },
                    { "mDataProp": 'order_no' },
                     {
                         "mDataProp": 'type', "mRender": function (data, type, full) {
                             return "退款冻结";
                         }
                     },
                    {
                        "mDataProp": 'money', "mRender": function (data, type, full) {
                            return "-" + data;
                        }
                    },
                    { "mDataProp": 'remark' }
                    , {
                        "mDataProp": 'id', "mRender": function (data, type, full) {
                            return ' <a href = "/Order/GoodsOrder/' + full.order_id + '" target="_blank" class="btn btn-default"  title="详情">订单详情</a> ';
                        }
                    }
                ]
            });
        }
        //欠款
        function GenerateTable5() {
            u_table5 = $('#DataList5').dataTable({
                "lengthChange": true,
                "searching": false,
                "ordering": false,
                "iDisplayLength": 10,
                "bProcessing": true,
                "bServerSide": true,
                "fnServerParams": function (aoData) {
                    //var datemin = $('#startTime').val();
                    //var datemax = $("#endTime").val();
                    aoData.push(
                        { "name": "dateMin", "value": "" },
                        { "name": "dateMax", "value": "" },
                        { "name": "type", "value": 2 }
                    );
                },
                "sAjaxSource": "/finance/FinanceReturnList",
                "aoColumns": [
                    {
                        "mDataProp": 'add_time', "mRender": function (data, type, full) {
                            return moment(data).format("YYYY-MM-DD HH:mm:ss");
                        }
                    },
                    //{ "mDataProp": 'id' },
                    { "mDataProp": 'return_no' },
                    { "mDataProp": 'order_no' },
                     {
                         "mDataProp": 'type', "mRender": function (data, type, full) {
                             return "退款欠款";
                         }
                     },
                    {
                        "mDataProp": 'money', "mRender": function (data, type, full) {
                            return "-"+data;
                        }
                    },
                    { "mDataProp": 'remark' }
                    ,{
                         "mDataProp": 'id', "mRender": function (data, type, full) {
                             return ' <a href = "/Order/GoodsOrder/' + full.order_id + '" target="_blank" class="btn btn-default"  title="详情">订单详情</a> ';
                         }
                     }
                ]
            });
        }
        /*增加*/
        function admin_add(title, url, w, h) {
            layer_show(title, url, "", w, h);
        };

        /*编辑*/
        function admin_edit(title, url, id, w, h) {
            layer_show(title, url, id, w, h);
        };
    </script>
}
